package com.wing.ext.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.common.util.PageBean;
import com.wing.ext.domain.Productgroup;

@Repository
public class ProductgroupDao extends CommonSpringJDBC<Productgroup, String> {

	public PageBean findPageList(int currentPage, int pageSize, Object... args) {
		String where= " 1=1 ";
		String sql1=" SELECT * FROM ext_productgroup where "+where+" ORDER BY id ASC " +
			" LIMIT "+(currentPage-1) * pageSize+","+pageSize;
		String sql2 = "select count(id) from  ext_productgroup  where"+where;
		String[] sqlArray = {sql1,sql2 };
		return super.findPageList(sqlArray, currentPage, pageSize);
	}
	
	public List<Map<String, Object>> findChildByID(String parentid,
			String siteId) {
		String sql = "select t.* from ext_productgroup t where t.pid=? and t.site_id=? order by order_num";
		Object [] objs = {parentid,siteId};
		return super.getSimpleJdbcTemplate().queryForList(sql,objs);
	}
}
